<?php

class setting_models_admin extends CI_Model{

	public function get_admin(){
		$where= array('code' => 'general');
		$query = $this->db->get_where('settings',$where);
		$setting=array();
		foreach ($query->result() as $row)
			$setting[$row->setting_key]=$row->setting;
		if(isset($setting)) return $setting;
		return false;
	}
	public function create($data){
		if(!empty($data)){
			foreach ($data as $setting_key=>$setting){
				$where= array('code' => 'general','setting_key'=>$setting_key);
				$query = $this->db->get_where('settings',$where,1);
				$post['code'] = 'general';
				$post['setting_key'] = $setting_key;
				$post['setting'] = $setting;
				if($query->num_rows){
					$this->db->update('settings', $post,$where);
				}else{
					$this->db->insert('settings', $post);
						
				}
					
			}
		}
		return false;
	}
}